// -------------------------------------------------------------
// Copyright(C) General Software, Inc., Minnesota, USA
// This block of code are developed independently by
// General Software, Inc., Minnesota. You may use it, but
// you may not modify it and sell it to anyone in the world.
// -------------------------------------------------------------
using System;

namespace PNet.Icap.PluginSDK.SQLCeAccess
{
	/// <summary>
	/// Helper functions for reflection
	/// </summary>
	public class ReflectionHelper
	{
        /// <summary>
        /// reflection helper
        /// </summary>
		public ReflectionHelper()
		{
		}
        /// <summary>
        /// has attribute
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="attrType"></param>
        /// <returns></returns>
		public static bool HasAttribute(object obj, Type attrType)
		{
			Attribute attr = Attribute.GetCustomAttribute(obj.GetType(), attrType, true);
			if (attr != null)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

        /// <summary>
        /// get attribute
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="attrType"></param>
        /// <returns></returns>
		public static Attribute GetAttribute (object obj, Type attrType)
		{
			Attribute attr = Attribute.GetCustomAttribute(obj.GetType(), attrType, true);
			return attr;
		}
        /// <summary>
        /// get field value
        /// </summary>
        /// <param name="attrField"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
		public static object GetFieldValue (object attrField, string fieldName)
		{
			return attrField.GetType().GetProperty (fieldName).GetValue(attrField, null);
		}
	}

	/// <summary>
	/// Use this attribute to label a class such as a page class to identify
	/// the developer who wrote the code
	/// </summary>
	[AttributeUsage(AttributeTargets.Class)] public class ATTR_Support : Attribute
	{
		private string _authorId;
        /// <summary>
        /// ATTR_Support
        /// </summary>
        /// <param name="authorId"></param>
		public ATTR_Support (string authorId)
		{
			_authorId = authorId;
		}
        /// <summary>
        /// Autor ID
        /// </summary>
		public string AuthorId 
		{
			get {return _authorId;}
		}
        /// <summary>
        /// ATTR_Support
        /// </summary>
		public ATTR_Support () {}
	}
}
// -------------------------------------------------------------
// Copyright(C) General Software, Inc., Minnesota, USA
// This block of code are developed independently by
// General Software, Inc., Minnesota. You may use it, but
// you may not modify it and sell it to anyone in the world.
// -------------------------------------------------------------

